import { gql } from 'apollo-server';

// A schema is a collection of type definitions (hence "typeDefs")
// that together define the "shape" of queries that are executed against
// your data.
export const typeDefs = gql`
  # Comments in GraphQL strings (such as this one) start with the hash (#) symbol.

  # This "Book" type defines the queryable fields for every book in our data source.
  type Book {
    title: String
    author: String
  }

  type ReponseList {
    code: Int
    message: String
    data: [Customer]
    pageInfo: PageInfo
  }

  type ReponseEdit {
    code: Int
    message: String
    data: String
  }

  type Customer {
    id: ID!
    name: String!
    age: Int
    sex: String!
    address: String!
    phone: String
    education: String!
  }

  type DetailInfo {
    code: Int
    message: String
    data: Customer
  }

  type PageInfo {
    page: Int
    pageSize: Int!
    total: Int
    totalPages: Int
  }

  # The "Query" type is special: it lists all of the available queries that
  # clients can execute, along with the return type for each. In this
  # case, the "books" query returns an array of zero or more Books (defined above).
  type Query {
    books: [Book]
    customers(name: String, address: String, age: Int, pageSize: Int, page: Int): ReponseList
    customer(id: String!): DetailInfo
  }

  type Mutation {
    removeCustomer(id: String!): ReponseEdit
    addCustomer(
      name: String
      sex: String
      address: String
      age: Int
      phone: String
      education: String
    ): ReponseEdit

    updateCustomer(
      id: String
      name: String
      sex: String
      address: String
      age: Int
      phone: String
      education: String
    ): ReponseEdit
  }
`;
